import {
	getAPPVersion
} from "@/api/config.js"

export default {
	name: "app_version",
	data() {
		return {};
	},
	methods: {
		updateApp() {
			let that = this;
			
			getAPPVersion().then((res) => {
				
				console.log("getappversion",res);

				if (res.data.code == 200) {
					let appData = res.data.data;
					if (appData != null && appData != '') {
						plus.runtime.getProperty(plus.runtime.appid, function(inf) {
		
							// console.log("inf",inf);
							if (Number(inf.versionCode) < Number(appData.app_version_code)) {
								// console.log("inf 1111111111");
								that.$store.dispatch("setAppUpdate", true)
								that.$store.dispatch("setAppUpdateInfo", appData)
							} else {
								// console.log("inf 222222222");
								if(appData.is_force == 1){
									that.$store.dispatch("setAppUpdate", true)
									that.$store.dispatch("setAppUpdateInfo", appData)
								}else{
									that.$store.dispatch("setAppUpdate", false)
									that.$store.dispatch("setAppUpdateInfo", {})
								}
							}
							
						});
					}
				}
			})
		}

	},
}